#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/wait.h>

const char * exe="otherExe";

int main(){
    pid_t id=fork();
    if(id==0){//子进程
        //char* const myargv[]={"ls","-l","-a",NULL};
        printf("before :i am a process,pid:%d,ppid:%d\n",getpid(),getppid());
        //sleep(5);
        //execl("/usr/bin/ls","ls","-l","-a",NULL);
        //execlp("ls","ls","-l","-a",NULL);
        //execv("/usr/bin/ls",myargv);
        //execl("/usr/bin/bash","bash","test.sh",NULL);
        char*const myargv[]={
            "otherExe",
            "-a",
            "-b",
            "-c",
            NULL 
        };
        execv("./otherExe",myargv);
        printf("after  :i am a process,pid:%d,ppid:%d\n",getpid(),getppid());
        exit(0);
    }
    //父进程
    pid_t ret=waitpid(id,NULL,0);
    if(ret>0){
        printf("wait success,father pid:%d,ret id:%d\n",getpid(),ret);
    }
    sleep(5);
    return 0;
}
